﻿@model Jb.Web.ViewModels.ContactViewModel
@using Jb.Web.Utility;

@{
    String pageTitle = "Edit Contact";
    if (Model != null && Model.ID == 0)
    {
        pageTitle = "Add New Contact";
    }
    ViewBag.Title = Html.GetPageTitle(pageTitle);
    ViewData[AppConstants.ViewDataKeys.SELECTED_MENU] = EmployerMenu.ManageContacts;
    bool _HasSaved = ViewData.HasSaved();
}

<div class="jb-page-heading">
    <h1>@pageTitle</h1>
    <div>Enter necessary information and then click the Save button.</div>
</div>
<div class="jb-page-content">
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)

    if (Model == null)
    {
        @: @Html.WarningMessageBox("Sorry! Requested Contact was not found for edit.")
    }
    else
    {
        if (_HasSaved)
        {
            @Html.SuccessMessageBox("Congratulations! The Contact information saved successfully")
        }
        else if (ViewData[AppConstants.ViewDataKeys.SAVED] != null && !_HasSaved)
        {
            @Html.WarningMessageBox("Sorry! we could not save the Contact.")
        }
		@Html.HiddenFor(model => model.ID)
        @Html.HiddenFor(model => model.CompanyID)		
		
		<div class="editor-label">
			@Html.LabelFor(model => model.Name)
		</div>
		<div class="editor-field">
			@Html.TextBoxFor(model => model.Name)
			@Html.ValidationMessageFor(model => model.Name)
		</div>
		<div class="editor-label">
			@Html.LabelFor(model => model.Gender)
		</div>
		@*<div class="editor-field">
			@Html.TextBoxFor(model => model.Gender)
			@Html.ValidationMessageFor(model => model.Gender)
		</div>*@
        <div class="editor-field jb-inline-label">
		    @Html.RadioButtonFor(model => model.Gender, "M", new { id = "rdnGender_1" }) <label for="rdnGender_1">Male</label>
            @Html.RadioButtonFor(model => model.Gender, "F", new { id = "rdnGender_0" }) <label for="rdnGender_0">Female</label>
		    @Html.ValidationMessageFor(model => model.Gender)
	    </div>
		<div class="editor-label">
			@Html.LabelFor(model => model.DateOfBirth)
		</div>
		<div class="editor-field">
			@Html.TextBoxFor(model => model.DateOfBirth, new { @class = "datepicker" })
			@Html.ValidationMessageFor(model => model.DateOfBirth)
		</div>
		<div class="editor-label">
			@Html.LabelFor(model => model.IsActive)
		</div>
        <div class="editor-field  jb-inline-label">
		    @Html.RadioButtonFor(model => model.IsActive, "true", new { id = "rdnIsActive_1" }) <label for="rdnIsActive_1">Yes</label>
            @Html.RadioButtonFor(model => model.IsActive, "false", new { id = "rdnIsActive_0" }) <label for="rdnIsActive_0">No</label>
		    @Html.ValidationMessageFor(model => model.IsActive)
	    </div>
		@*<div class="editor-field">
			@Html.TextBoxFor(model => model.IsActive)
			@Html.ValidationMessageFor(model => model.IsActive)
		</div>
		<div class="editor-label">
			@Html.LabelFor(model => model.IsDeleted)
		</div>
		<div class="editor-field">
			@Html.TextBoxFor(model => model.IsDeleted)
			@Html.ValidationMessageFor(model => model.IsDeleted)
		</div>*@
		<div class="editor-label">
			@Html.LabelFor(model => model.FatherName)
		</div>
		<div class="editor-field">
			@Html.TextBoxFor(model => model.FatherName)
			@Html.ValidationMessageFor(model => model.FatherName)
		</div>
		<div class="editor-label">
			@Html.LabelFor(model => model.MotherName)
		</div>
		<div class="editor-field">
			@Html.TextBoxFor(model => model.MotherName)
			@Html.ValidationMessageFor(model => model.MotherName)
		</div>
		<div class="editor-label">
			@Html.LabelFor(model => model.SpouceName)
		</div>
		<div class="editor-field">
			@Html.TextBoxFor(model => model.SpouceName)
			@Html.ValidationMessageFor(model => model.SpouceName)
		</div>
        <div class="jb-group-title">
            <a href="javascript:void(0);" data-toggle="collapse" data-target="#divAddress">
                <i id="iAddressToggle" class="icon-minus-sign"></i>Contact Address
            </a>
        </div>
        <div id="divAddress" class="collapse in">
        @Html.EditorFor(model => model.Address)
        </div>    
		@*@Html.HiddenFor(model => model.CreatedOn)
		@Html.HiddenFor(model => model.ModifiedOn)*@
		<div class="jb-button-container">
			<button class="btn btn-primary" type="submit" data-loading-text="Saving...">Save</button> 
			@Html.PrivateLink("Back to Contact List", "List", "Contact", new { @class = "btn" })
		</div>		
    }
}
</div>
@section PageHeadSection
{
    <link href="@Url.Content("~/Content/themes/jb-ui/jquery.ui.all.css")" rel="stylesheet" type="text/css" />    
}
@section JavaScriptPlaceHolder
{
    @Html.JavaScript("jquery.validate.min.js", Url)
    @Html.JavaScript("jquery.validate.unobtrusive.min.js", Url)
    @Html.JavaScript("jquery-ui-1.8.11.min.js", Url)
    @Html.Partial("_DatePicker")
    <script language="javascript" type="text/javascript">
        $(document).ready(function () {
            $('#divAddress').on('show', function () { $('#iAddressToggle').removeClass('icon-plus-sign').addClass('icon-minus-sign'); })
                        .on('hide', function () { $('#iAddressToggle').removeClass('icon-minus-sign').addClass('icon-plus-sign'); });
        });
    </script>
}

